package com.googlecode.mailnet.math.distribution;

import com.googlecode.mailnet.math.RandomUtil;

/**
 * @author Iskander Akishev
 */
class ExponentialDistribution implements Distribution {
    private final double scale;

    ExponentialDistribution(double scale) {
        if (scale <= 0) {
            throw new IllegalArgumentException(String.format("scale must be positive (" + scale + ")"));
        }
        this.scale = scale;
    }

    public double getValue() {
        return -scale * Math.log(RandomUtil.nextDouble());
    }
}
